package oops.exception;

public class Calculator {

	private void validate(int number) throws MyCheckedException {
		if (number < 0 || number > 100) {
			throw new MyCheckedException("number " + number
					+ "  should be in the range of 0 to 100");
		}
	}

	public int add(int a, int b) throws MyCheckedException {

		validate(a);

		validate(b);

		return a + b;

	}

	public int substract(int a, int b) {

		if (b > a) {
			// MyRuntimeException exception = new
			// MyRuntimeException("b can not be more than a");
			// throw exception;
			throw new MyRuntimeException("b can not be more than a");

		}
		return a - b;
	}

}
